package com.hidt.shop.controller;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hidt.shop.domain.Admin;
import com.hidt.shop.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Set;

@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;
    /**
     * 管理员登录
     *@参数  admin
     *@返回值  String
     *@创建人  lmf
     *@创建时间  2021/1/19
     */
    @RequestMapping(value = "/adminlogin")
    @ResponseBody
        public String UserLogin(@RequestBody Admin admin){
        int i = adminService.AdminLogin(admin.getAdmin_name(), admin.getAdmin_pwd());
        if(i==2) {
            System.out.println("登录成功");
            return "登录成功";
//            return new ResultInfo(2,"登录成功");
        }
        else if(i==0) {
            System.out.println("用户名不存在");
            return "用户名不存在";
//            return new ResultInfo(0,"用户名不存在");
        }else {
            System.out.println("密码错误");
            return "密码错误";
//            return new ResultInfo(1,"密码错误");
        }
    }

}
